home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #define STDC_HEADERS 1
- #define HAVE_STRING_H 1
- #define HAVE_ALLOCA_H 1
- #include "regex.h"
- #include "regex.c"
-
- void* C_REGEXP_compile( void* string, void* nocase )
- {
- int res,flags;
- regex_t *r;
- /* re_syntax_options = RE_SYNTAX_EGREP; */
- r = (regex_t*)malloc(sizeof(regex_t));
- flags = REG_EXTENDED | ( ((int)nocase!=0) ? REG_ICASE : 0 );
- res = regcomp(r,(char*)string,flags);
- if( !res ) return (void*)r;
- free(r);
- return (void*)0;
- }
-
- void C_REGEXP_match( void* regexpr, void* string, void* beg, void* end)
- {
- int res;
- regmatch_t match;
- res = regexec((regex_t*)regexpr,(char*)string,
- 1,&match,0);
- if( res ) {
- *(int*)beg = -1;
- *(int*)end = -1;
- } else {
- *(int*)beg = (int)(match.rm_so);
- *(int*)end = (int)(match.rm_eo);
- }
- }
-
- void C_REGEXP_free( void* regexpr )
- {
- regfree( (regex_t*)regexpr );
- }
-
-
-